home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr25
/
os2dbutl.zip
/
LUDOSPY.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-09
|
122KB
|
3,036 lines
/*............................................................................
. .
. .
. .
. --- Series III Life and Health Presents --- .
. .
. .
. .
. .
. Program ID......: LUDOSNAP.C .
. .
. Program Title...: .
. .
. Version Number..: 1.00 .
. .
. Operating System: OS/2 .
. .
. Description.....: .
. .
. .
. .
. Parameters: .
. .
. Type Name Description .
. ------------ -------------- ---------------------------- .
. N/A .
. .
. .
. Return Values: .
. .
. Type Value #define Description .
. -------- ----- ---------------- ----------------------- .
. N/A .
. .
. .
. Application Function Calls (Internal): .
. .
. Function Name Description .
. ------------------------ -------------------------------- .
. .
. .
. Application Function Calls (External): .
. .
. Function Name Description .
. ------------------------ -------------------------------- .
. N/A .
. .
. Special Processing: .
. .
. .
. .
. Internal Tables: .
. .
. Table Name Description .
. -------------------------- -------------------------------- .
. N/A .
. .
. .
. Application Specific Hungarian Prefixes: .
. .
. Prefix Description .
. ------ -------------------------------------------- .
. N/A .
. .
. .
. Member of Object Library: N/A .
. .
. Member of Dynamic Link Library: N/A .
. .
. .
. .
..............................................................................
. .
. M A I N T E N A N C E L O G .
. .
. .
. SI Number Date PGMR Description .
. --------- -------- ---- ------------------------------ .
. .
. .
............................................................................*/
/*....................................................................
: :
: Defines :
: :
:...................................................................*/
#define INCL_BASE
#define EXTERN
#define TRUE 1
#define FALSE 0
#define SLEEP_TIME 950L
#define STACK_SIZE 1024
#define ARGS NULL
#define MAX_USERS 101
#define DELAY 1000L
#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define WHITE 7
#define GREY 8
#define LT_BLUE 9
#define LT_GREEN 10
#define LT_CYAN 11
#define LT_RED 12
#define LT_MAGENTA 13
#define YELLOW 14
#define BRI_WHITE 15
#define LT_RED_BLINK 28
#define WM_REDRAW WM_USER +251
#define WM_FINISH WM_USER +252
/*....................................................................
: :
: OS/2 include headers :
: :
:...................................................................*/
#include "LUDOSPY.H"
/*....................................................................
: :
: SQL include headers :
: :
:...................................................................*/
#include <sql.h>
#include <sqlca.h>
#include <sqlenv.h>
#include <sqlutil.h>
/*....................................................................
: :
: Global variables :
: :
:...................................................................*/
char sz_log[15];
char sz_mode[9];
char sz_stats[256];
char sz_code[20];
char sz_title[80];
char sz_dbase[10];
char sz_buff[81];
char sz_conn[5];
char sz_conns[10];
char sz_nodename[9];
char sz_partner_lu[9];
char sz_local_lu[9];
char sz_comment[31];
char sz_db_entry[9];
char sz_time_out[30];
char sz_date_time[26];
char sz_user_buff[256];
char sz_alias[25][9];
char sz_node[25][9];
char sz_un_alias[25][9];
char sz_un_nodename[25][9];
char sz_trans_con[9];
char sz_req_con[9];
char sz_req_cur[9];
char sz_rds_name[9];
char sz_new_title[22];
char sz_scan[10];
BYTE stack[STACK_SIZE];
BYTE wch_stack[STACK_SIZE];
unsigned short us_db_count;
unsigned short us_count_dir;
unsigned short us_count_node;
unsigned short us_row;
unsigned short us_col;
unsigned short us_hand_dir;
unsigned short us_hand_node;
unsigned short us_scan;
HWND hWndDbDlg;
HWND hWndReFresh;
/*....................................................................
: :
: Structures :
: :
:...................................................................*/
struct sqlca sqlca;
/* System Status data structure */
struct dbstat
{
unsigned long current_time;
long time_zone_disp1;
unsigned char product_name[SQL_PRODNAME_SZ];
unsigned char component_id[SQL_COMPID_SZ];
unsigned char reserved1; /* Reserved byte */
unsigned char release_lvl[SQL_RLSLVL_SZ];
unsigned char corr_serv_lvl[SQL_CORRLVL_SZ];
unsigned long backup_time; /* Last backup time */
long time_zone_disp2; /* Time zone of backup time */
unsigned short connects; /* Number of current users */
unsigned char db_alias[SQL_DBSTAT_ALIAS_SZ]; /* Alias name */
unsigned char db_name[SQL_DBSTAT_DBNAME_SZ]; /* Database name */
unsigned char location; /* Local / Remote Database */
unsigned char reserved2; /* Reserved byte */
unsigned char drive[SQL_DRIVE_SZ]; /* Drive containing database */
unsigned char node[SQL_NNAME_SZ]; /* Node containing database */
unsigned char db_type[SQL_DBTYP_SZ]; /* "OS2 DBM" */
struct userstat
{
unsigned long con_trans; /* Transactions since connect */
unsigned long con_reqs; /* Requests since connect */
unsigned long cur_reqs; /* Requests current transact */
unsigned long connect_time; /* Time since connect */
unsigned long trans_time; /* Time since current transact*/
unsigned char authid[SQL_USERID_SZ];/* User's Id */
unsigned char node[SQL_NNAME_SZ]; /* Nodename of connected user */
unsigned short authority_lvl; /* User's authority level */
unsigned char trans_state; /* Transaction state */
unsigned char lock_state; /* Transaction lock state */
} ustat[MAX_USERS];
} *pdbstat;
struct dbstat basestat;
time_t bintime;
time_t con_time;
struct tm *curtime;
struct tm *out_time;
struct sqlca sqlca;
struct sqledinfo *st_info;
struct sqleninfo *st_node;
struct sql_authorizations st_auth, *p_auth = &st_auth;
/*....................................................................
: :
: Bit structures :
: :
:...................................................................*/
struct logical
{
unsigned cat : 1; /*TRUE catolog database */
unsigned node : 1; /*TRUE catolog node */
unsigned noconn : 1; /*TRUE there is no connections */
unsigned append : 1; /*TRUE append log file */
unsigned over : 1; /*TRUE overwrite log file */
unsigned none : 1; /*TRUE do not use log file */
unsigned tend : 1; /*TRUE to end the refresh thread */
unsigned draw : 1; /*TRUE if screen is already drawing */
unsigned time : 1; /*TRUE if refresh time has expired */
}
bit_flag;
/*....................................................................
: :
: File Structures :
: :
:...................................................................*/
FILE *spyfile;
/*....................................................................
: :
: function prototypes :
: :
:...................................................................*/
void dir_scan(void);
void db_crash(void);
void get_time(void);
void node_scan(void);
void sort_users(void);
void write_db_stats(void);
void write_user_stats(void);
void refresh_thread(void);
void wch_thread(void);
/***************************************************************************/
/* */
/* Presentation Manager Program Main Body */
/* */
/* The following routine is the Presentation Manager program Main Body. */
/* The Main Body of a PM program is concerned with associating the */
/* application with the Presentation Manager system, creating its */
/* message queue, registering and displaying its main window, servicing */
/* its message queue during the time that the application is active, */
/* and disassociating the application from PM when the user is finished */
/* with the application. The remaining parts of this source module that */
/* are concerned with the Presentation Manager are the application's */
/* window procedures (main window procedure, child window procedures, */
/* and dialog window procedures) that process the messages associated */
/* with the application's various windows. */
/* */
/***************************************************************************/
SHORT cdecl main(argc, argv)
int argc;
char *argv[];
{
QMSG qmsg; /* MSG structure to store your messages */
PID pid; /* Process identifier for adding name to switch list */
TID tid; /* Thread identifier */
static CHAR szTitle[8];
/* The WinInitialize routine initializes the Presentation Manager */
/* facilities for use by this application and returns a handle to the */
/* anchor block assigned to the application by PM. */
bit_flag.append = FALSE;
bit_flag.over = FALSE;
bit_flag.none = TRUE;
bit_flag.draw = FALSE;
us_scan = 30;
SQLGSTAR();
if((hAB = WinInitialize(0)) == 0)
return(FALSE);
/* The WinCreateMsgQueue call creates a message queue for this application*/
if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
return(FALSE);
/* The following function registers the classes of all application windows*/
if(!cwRegisterClass())
return(FALSE);
/**************************************************************************/
/* IPF Initialization Structure */
/**************************************************************************/
hiLUDOSPYHelp.cb = sizeof(HELPINIT); /* size of init structure */
hiLUDOSPYHelp.ulReturnCode = 0;
hiLUDOSPYHelp.pszTutorialName = 0; /* no tutorial */
hiLUDOSPYHelp.phtHelpTable = (PVOID)(0xffff0000 | ID_LUDOSPY);
hiLUDOSPYHelp.hmodAccelActionBarModule = 0;
hiLUDOSPYHelp.idAccelTable = 0;
hiLUDOSPYHelp.idActionBar = 0;
hiLUDOSPYHelp.pszHelpWindowTitle = "LUDOSPY";
hiLUDOSPYHelp.hmodHelpTableModule = 0;
hiLUDOSPYHelp.usShowPanelId = 0;
hiLUDOSPYHelp.pszHelpLibraryName = "LUDOSPY.HLP";
/**************************************************************************/
/* Create Instance of IPF */
/**************************************************************************/
hWndLUDOSPYHelp = WinCreateHelpInstance(hAB, &hiLUDOSPYHelp);
if(!hWndLUDOSPYHelp || hiLUDOSPYHelp.ulReturnCode)
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ)"No help is available.",
(PSZ) szAppName,
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hWndLUDOSPYHelp);
}
/* The CreateWindow function creates a frame window for this application's*/
/* top window, and set the window's size and location as appropriate. */
WinLoadString(hAB, 0, IDS_TITLE, 8, szTitle);
hWndFrame = cwCreateWindow((HWND)HWND_DESKTOP,
FCF_TITLEBAR |
FCF_SYSMENU |
FCF_MINBUTTON |
FCF_MAXBUTTON |
FCF_SIZEBORDER |
FCF_MENU |
FCF_ACCELTABLE |
FCF_SHELLPOSITION,
szAppName,
szTitle,
ID_LUDOSPY,
0, 0,
0, 0,
&hWndClient,
0L,SWP_MAXIMIZE | SWP_SHOW);
if(hWndFrame == 0)
return(FALSE);
/**************************************************************************/
/* Associate Instance of IPF */
/**************************************************************************/
if(hWndLUDOSPYHelp)
WinAssociateHelpInstance(hWndLUDOSPYHelp, hWndFrame);
/* The following inline routine fills out the application's switch control*/
/* structure with the appropriate information to add the application's */
/* name to the OS/2 Task Manager List, a list of the jobs currently */
/* running on the computer. */
WinQueryWindowProcess(hWndFrame, &pid, &tid);
Swctl.hwnd = hWndFrame; /* Frame window handle */
Swctl.idProcess = pid; /* Process identifier */
Swctl.uchVisibility = SWL_VISIBLE; /* visibility */
Swctl.fbJump = SWL_JUMPABLE; /* Jump indicator */
strcpy(Swctl.szSwtitle, szTitle); /* Frame window title */
hSwitch = WinAddSwitchEntry(&Swctl);
/* The following is the message loop for the application. */
while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
WinDispatchMsg(hAB,(PQMSG)&qmsg);
/* Perform clean up before exiting application. */
/**************************************************************************/
/* Destroy Instance of IPF */
/**************************************************************************/
if(hWndLUDOSPYHelp)
WinDestroyHelpInstance(hWndLUDOSPYHelp);
/* The following routine destroys the application's frame window (which */
/* also destroys its child windows), destroys its message queue, and */
/* disassociates the application from the Presentation Manager system. */
WinDestroyWindow(hWndFrame); /* Destroy the frame window */
WinDestroyMsgQueue(hMQ); /* Destroy this application's message queue */
WinTerminate(hAB); /* Terminate this application's use of the */
/* Presentation Manager resources */
} /* end of main */
/* The following Dialog box calls are generated for the dialog boxes that */
/* have been selected as "Unlinked" dialog boxes. To use these calls, */
/* simply copy them to the appropriate location in the application. */
#if 0
WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CATMsgProc,
0, IDLG_CAT, (PBYTE)hWnd);
WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)NODEMsgProc,
0, IDLG_NODE, (PBYTE)hWnd);
WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)NO_CONMsgProc,
0, IDLG_NO_CON, (PBYTE)hWnd);
WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)STATUSMsgProc,
0, IDLG_STATUS, (PBYTE)hWnd);
#endif
/***************************************************************************/
/* */
/* Main Window Procedure */
/* */
/* This procedure provides service routines for the general PM events */
/* (messages) that PM sends to the window, as well as the user */
/* initiated events (messages) that are generated when the user selects */
/* the action bar and pulldown menu controls or the corresponding */
/* keyboard accelerators. */
/* */
/* The SWITCH statement shown below distributes the window messages to */
/* the respective message service routines, which are set apart by the */
/* CASE statements. The window procedures must provide an appropriate */
/* service routine for its end user initiated messages, as well as the */
/* general PM messages (like the WM_CLOSE message). If a message is */
/* sent to this procedure for which there is no programmed CASE clause */
/* (i.e., no service routine), the message is defaulted to the */
/* WinDefWindowProc function, where it is disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY WndProc(hWnd, message, mp1, mp2)
HWND hWnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{ /* Beginning of message processor */
HPS hPS; /* Handle for the Presentation Space */
RECTL rClient; /* Handle to rectangle formed by client area */
USHORT rc; /* common return code value */
switch(message)
{
case WM_COMMAND:
/* The PM messages for action bar and pulldown menu items are */
/* processed in this routine. */
switch(SHORT1FROMMP(mp1))
{
case IDM_F_EXIT:
/* Place User Code to respond to the */
/* Menu Item Named "E~xit" here. */
WinPostQueueMsg(hMQ, WM_QUIT, NULL, NULL);
break;
case IDM_P_SCANINTERVAL:
/* This makes a call to the dialog box named */
/* "INTERVAL" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)INTERVALMsgProc,
0, IDLG_INTERVAL, (PBYTE)hWnd);
break;
case IDM_P_FILEOPTIONS:
/* This makes a call to the dialog box named */
/* "FILES" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)FILESMsgProc,
0, IDLG_FILES, (PBYTE)hWnd);
break;
case IDM_P_DATABASE:
if (!WinIsWindow(hAB, hWndDATABASE))
{
hWnd = WinLoadDlg(HWND_DESKTOP, hWnd,
(PFNWP)DATABASEMsgProc, 0, IDLG_DATABASE, (PBYTE)hWnd);
}
else
WinSetFocus(HWND_DESKTOP, hWndDATABASE);
break;
case IDM_P_CATOLOGDATABASE:
/* This makes a call to the dialog box named */
/* "CAT" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)CATMsgProc,
0, IDLG_CAT, (PBYTE)hWnd);
break;
case IDM_P_UNCATOLOGDATABASE:
/* This makes a call to the dialog box named */
/* "UN_CAT" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)UN_CATMsgProc,
0, IDLG_UN_CAT, (PBYTE)hWnd);
break;
case IDM_P_CATOLOGNODE:
/* This makes a call to the dialog box named */
/* "NODE" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)NODEMsgProc,
0, IDLG_NODE, (PBYTE)hWnd);
break;
case IDM_P_UNCATOLOGNODE:
/* This makes a call to the dialog box named */
/* "UN_NODE" rc will receive the return code */
/* sent when the dialog box is closed */
rc = WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)UN_NODEMsgProc,
0, IDLG_UN_NODE, (PBYTE)hWnd);
break;
case IDM_H_HELPFORHELP:
if(hWndLUDOSPYHelp)
WinSendMsg(hWndLUDOSPYHelp, HM_DISPLAY_HELP, 0L, 0L);
break;
default:
break; /* End of default case for switch(mp1) */
}
break; /* End of WM_COMMAND */
case HM_QUERY_KEYS_HELP:
/* If the user requests Keys Help from the help pulldown, */
/* IPF sends the HM_QUERY_KEYS_HELP message to the application, */
/* which should return the panel id of the Keys Help panel */
return((MRESULT)999);
break;
case HM_ERROR:
/* If an IPF error occurs, an HM_ERROR message will be sent to */
/* the application. */
if(hWndLUDOSPYHelp && ((ULONG)mp1) == HMERR_NO_MEMORY)
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Terminated Due to Error",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance(hWndLUDOSPYHelp);
}
else
{
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Error Occurred",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
}
break;
case WM_CREATE:
/* The WM_CREATE message is sent to a window when an application*/
/* requests that the window be created. The window procedure */
/* for the new window receives this message after the window is */
/* created, but before the window becomes visible. */
/* */
cwSetInitDlgStatus(hWnd);
break; /* End of WM_CREATE */
case WM_MOUSEMOVE:
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break;
case WM_SIZE: /* code for sizing client area */
break; /* End of WM_SIZE */
case WM_PAINT: /* code for the window's client area */
/* Obtain a handle to a cache presentation space */
hPS = WinBeginPaint(hWnd, 0, 0);
/* Determine the size of the client area */
WinQueryWindowRect(hWnd, &rClient);
/* Fill the background with the default background color */
WinFillRect(hPS, &rClient, CLR_CYAN);
/* return presentation space to state before WinBeginPaint */
WinEndPaint(hPS);
break; /* End of WM_PAINT */
case WM_CLOSE: /* close the window */
if(hWnd != hWndClient)
break;
cwFreeDlgMemory(hWnd);
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of WM_CLOSE */
default:
/* For any message for which you don't specifically provide a */
/* service routine, you should return the message to PM using */
/* the WinDefWindowProc function. */
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break; /* End of default */
}
return(0L);
} /* End of WndProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY INTERVALMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
WinSendDlgItemMsg(hWndDlg, 257, EM_SETTEXTLIMIT, (MPARAM)4, NULL);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 257: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
WinQueryDlgItemText(hWndDlg, 257,
sizeof(sz_scan),
sz_scan);
us_scan = atoi(sz_scan);
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case 260: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of INTERVALMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY FILESMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
bit_flag.append = FALSE;
bit_flag.over = FALSE;
bit_flag.none = TRUE;
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* Radiobutton text: "~Append" */
bit_flag.append = TRUE;
bit_flag.over = FALSE;
bit_flag.none = FALSE;
break;
case 257: /* Radiobutton text: "Over~write" */
bit_flag.over = TRUE;
bit_flag.none = FALSE;
bit_flag.append = FALSE;
break;
case 258: /* Radiobutton text: "~None" */
bit_flag.none = TRUE;
bit_flag.append = FALSE;
bit_flag.over = FALSE;
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
if (bit_flag.append)
{
if((spyfile = fopen(sz_log, "a")) == NULL)
{
perror("Can't open log file...");
}
}
if (bit_flag.over)
{
if((spyfile = fopen(sz_log, "w")) == NULL)
{
perror("Can't open log file...");
}
}
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case 261: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of FILESMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY DATABASEMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i, us_item_index;
static HWND hWndParent;
static USHORT rc;
char *pspace;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
hWndDbDlg = hWndDlg;
SQLGDOPS('0', &us_hand_dir, &us_count_dir, &sqlca);
strcpy(sz_alias[0], "--New--");
for(i=1;i<us_count_dir+1;i++)
{
SQLGDGNE(us_hand_dir, &st_info, &sqlca);
strncpy(sz_alias[i], st_info->alias, 8);
sz_alias[i][8] = '\0';
}
SQLGDCLS(us_hand_dir, &sqlca);
for(i=0;i<us_count_dir+1;i++)
{
WinSendDlgItemMsg(hWndDlg,
256,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_alias[i]));
}
break;
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* List box */
us_item_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
256,
LM_QUERYSELECTION,
(short)NULL,
(short)NULL);
if (us_item_index == LIT_NONE)
{
strcpy(sz_dbase,"--New--");
}
else
{
strcpy(sz_dbase, sz_alias[us_item_index]);
if ((pspace = strchr(sz_dbase, ' ')) != NULL)
{
*pspace = '\0';
}
sz_dbase[8] = '\0';
strcpy(sz_log, sz_dbase);
sz_log[8] = '\0';
strcat(sz_log, ".LOG");
strcpy(sz_new_title, "Ludospy on ");
strcat(sz_new_title, sz_dbase);
WinSetWindowText(hWndFrame, sz_new_title);
/*
SQLGSTRD(0, strlen(sz_dbase), 'S', &sqlca, 0, sz_dbase);
if (sqlca.sqlcode != 0)
{
DosBeep(500,500);
}
st_auth.sql_authorizations_len = sizeof(st_auth);
SQLGADAU(p_auth, &sqlca);
if (sqlca.sqlcode != 0)
{
DosBeep(500,500);
}
*/
}
break;
}
break;
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
WinDestroyWindow(hWndDlg);
hWndDATABASE = 0;
if ((strcmp(sz_dbase, "--New--")) == 0)
{
rc = WinDlgBox(HWND_DESKTOP, hWndDlg,
(PFNWP)CATMsgProc,
0, IDLG_CAT, (PBYTE)hWndParent);
if (rc)
{
WinSendDlgItemMsg(hWndDlg,
256,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_alias[us_count_dir]));
}
}
else
{
bit_flag.noconn = FALSE;
rc = WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, /* hWndDlg */
NULL, NULL, /* 0, (PFNWP)STATUSMsgProc, */
IDLG_STATUS, NULL); /* (PBYTE)hWndParent); */
if (bit_flag.noconn)
{
WinShowWindow(hWndDbDlg,
(BOOL)FALSE);
WinDlgBox(HWND_DESKTOP, hWndDlg, (PFNWP)NO_CONMsgProc,
0, IDLG_NO_CON, (PBYTE)hWndDlg);
WinShowWindow(hWndDbDlg,
(BOOL)TRUE);
}
if (rc)
{
WinDismissDlg(hWndDlg, FALSE);
}
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDestroyWindow(hWndDlg);
hWndDATABASE = 0;
break;
case 259: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of DATABASEMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY STATUSMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
HPS hPS; /* Handle for the Presentation Space */
RECTL rDlg; /* Handle to rectangle formed by client area */
static SHORT sfValidate = TRUE;
INT i, j, k;
static HWND hWndParent;
static HWND hWndLBox;
static USHORT cols[] = { 3, 70, 80, 9, 9, 9, 9, 9, 9, 9, 20, 9, 9, 9, 9, 9, 9, 9, 20, 9, 9, 9, 9, 9, 9, 9, 32, 28, 45 };
char sz_temp[9];
char *p_til;
char *p_colon;
short us_len;
USHORT us_ret, us_ret_wch;
PBYTE p_stack;
PBYTE p_wch_stack;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
hWndReFresh = hWndDlg;
p_stack = stack;
p_wch_stack = wch_stack;
bit_flag.tend = FALSE;
case WM_REDRAW:
bit_flag.draw = TRUE;
WinSendDlgItemMsg(hWndDlg, 256, LM_DELETEALL, 0L, 0L);
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE));
bit_flag.time = FALSE;
us_ret_wch = _beginthread((PVOID)wch_thread,
p_wch_stack,
STACK_SIZE,
ARGS);
us_db_count = 1;
SQLGOPST(3, 1, strlen(sz_dbase), &sz_dbase, &us_db_count,
&basestat, &sqlca);
if (sqlca.sqlcode != 0)
{
db_crash();
}
if (!bit_flag.none)
{
write_db_stats();
}
if (basestat.connects == 0)
{
bit_flag.noconn = TRUE;
SQLGFREE(&sqlca);
if (sqlca.sqlcode != 0)
{
db_crash();
}
WinDismissDlg(hWndDlg, FALSE);
}
else
{
SQLGUSER(strlen(sz_dbase), &sz_dbase, &basestat.ustat, &sqlca);
if ((sqlca.sqlcode != 0) && (sqlca.sqlcode != -1203))
{
db_crash();
}
SQLGFREE(&sqlca);
if (sqlca.sqlcode != 0)
{
db_crash();
}
bit_flag.time = TRUE;
sort_users();
if (!bit_flag.none)
{
write_user_stats();
fclose(spyfile);
}
if (basestat.location == 'R')
{
strcpy(sz_title, "Remote: ");
}
else
{
strcpy(sz_title, "Local: ");
}
strncat(sz_title, basestat.db_name, 8);
strcat(sz_title, " Alias: ");
strncat(sz_title, basestat.db_alias, 8);
if (basestat.location == 'R')
{
strcat(sz_title, " Node: ");
strncat(sz_title, basestat.node, 8);
}
strcat(sz_title, " Connects: ");
itoa(basestat.connects, sz_conn, 10);
strcat(sz_title, sz_conn);
WinSetWindowText(hWndDlg, sz_title);
for(j=0;j<basestat.connects;j++)
{
memset(sz_trans_con, '\0', sizeof(sz_trans_con));
memset(sz_req_con, '\0', sizeof(sz_req_con));
memset(sz_req_cur, '\0', sizeof(sz_req_cur));
memset(sz_temp, '\0', sizeof(sz_temp));
memset(sz_stats, '\0', sizeof(sz_stats));
ltoa(basestat.ustat[j].con_trans, sz_trans_con, 10);
ltoa(basestat.ustat[j].con_reqs, sz_req_con, 10);
ltoa(basestat.ustat[j].cur_reqs, sz_req_cur, 10);
strcpy(sz_temp, sz_trans_con);
us_len = strlen(sz_trans_con);
for(k=0;k<(8 - us_len);k++)
{
sz_trans_con[k] = ' ';
}
strcat(sz_trans_con, sz_temp);
sz_trans_con[8] = '\0';
strcpy(sz_temp, sz_req_con);
us_len = strlen(sz_req_con);
for(k=0;k<(8 - us_len);k++)
{
sz_req_con[k] = ' ';
}
strcat(sz_req_con, sz_temp);
sz_req_con[8] = '\0';
strcpy(sz_temp, sz_req_cur);
us_len = strlen(sz_req_cur);
for(k=0;k<(8 - us_len);k++)
{
sz_req_cur[k] = ' ';
}
strcat(sz_req_cur, sz_temp);
sz_req_cur[8] = '\0';
strcpy(sz_stats, "~");
strncat(sz_stats, basestat.ustat[j].authid, 8);
strcat(sz_stats, "~");
strncat(sz_stats, basestat.ustat[j].node, 8);
strcat(sz_stats, "~");
if (( p_til = strrchr(sz_stats, '~')) != NULL)
{
p_til++;
for(k=0;k<strlen(sz_trans_con);k++)
{
*p_til = sz_trans_con[k];
p_til++;
*p_til = '~';
p_til++;
}
}
if (( p_til = strrchr(sz_stats, '~')) != NULL)
{
p_til++;
for(k=0;k<strlen(sz_req_con);k++)
{
*p_til = sz_req_con[k];
p_til++;
*p_til = '~';
p_til++;
}
}
if (( p_til = strrchr(sz_stats, '~')) != NULL)
{
p_til++;
for(k=0;k<strlen(sz_req_cur);k++)
{
*p_til = sz_req_cur[k];
p_til++;
*p_til = '~';
p_til++;
}
}
if (basestat.ustat[j].trans_state == 'S')
{
strcat(sz_stats, "S");
}
if (basestat.ustat[j].trans_state == 'R')
{
strcat(sz_stats, "R");
}
if (basestat.ustat[j].trans_state == 'C')
{
strcat(sz_stats, "C");
}
strcat(sz_stats, "~");
if (basestat.ustat[j].lock_state == 'N')
{
strcat(sz_stats, "N");
}
if (basestat.ustat[j].lock_state == 'W')
{
strcat(sz_stats, "W");
}
get_time();
con_time = bintime - basestat.ustat[j].connect_time;
out_time = localtime(&con_time);
sprintf(sz_time_out, "%s", asctime(out_time));
p_colon = strchr(sz_time_out, ':');
p_colon--;
p_colon--;
strcat(sz_stats, "~");
strncat(sz_stats, p_colon, 8);
WinSendDlgItemMsg(hWndDlg,
256,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_stats));
} /* end of for j */
}
WinSetPointer(HWND_DESKTOP,
WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,FALSE));
if (message == WM_INITDLG)
{
us_ret = _beginthread((PVOID)refresh_thread,
p_stack,
STACK_SIZE,
ARGS);
}
bit_flag.draw = FALSE;
break; /* End of WM_INITDLG and WM_REDRAW */
case WM_MEASUREITEM:
return( LimitLBox( hWndDlg, 1750 ) );
break;
case WM_DRAWITEM:
if ( SHORT1FROMMP( mp1 ) != 256)
{
return ( 0L );
}
return( AlignLBox( hWndDlg, 256, cols, mp2 ) );
break;
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* List box */
{
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
WinShowWindow(hWndDbDlg,
(BOOL)FALSE);
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
bit_flag.tend = TRUE;
WinDismissDlg(hWndDlg, FALSE);
break;
case 257: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
// case WM_PAINT: /* code for the window's client area */
// /* Obtain a handle to a cache presentation space */
//
// hWndLBox = WinWindowFromID(hWndDlg, 256);
//
// hPS = WinBeginPaint(hWndLBox, 0, 0);
//
// /* Determine the size of the client area */
// WinQueryWindowRect(hWndLBox, &rDlg);
//
// /* Fill the background with the default background color */
// WinFillRect(hPS, &rDlg, CLR_BLUE);
//
// /* return presentation space to state before WinBeginPaint */
// WinEndPaint(hPS);
// break; /* End of WM_PAINT */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of STATUSMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY CATMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i, us_item_index, us_item_len;
INT us_node_index;
static HWND hWndParent;
CATStruct FAR *Cat;
static USHORT rc;
char *pspace;
static char ch_type;
static char ch_drive;
switch(message)
{
case WM_INITDLG:
Cat = (CATStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CAT);
memset(sz_rds_name, '\0', sizeof(sz_rds_name));
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
/* Initialize radio button control: YourWindowsTitleGoesHere */
WinPostMsg(hWndDlg, WM_CONTROL,
MPFROMSHORT(Cat->YourWindowsTitleGoesHere), 0L);
WinSendDlgItemMsg(hWndDlg, 262, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
WinSendDlgItemMsg(hWndDlg, 263, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
WinSendDlgItemMsg(hWndDlg, 264, EM_SETTEXTLIMIT, (MPARAM)30, NULL);
WinSendDlgItemMsg(hWndDlg, 270, EM_SETTEXTLIMIT, (MPARAM)1, NULL);
SQLGNOPS(&us_hand_node, &us_count_node, &sqlca);
strcpy(sz_node[0], "--New--");
for(i=1;i<us_count_node+1;i++)
{
SQLGNGNE(us_hand_node, &st_node, &sqlca);
strncpy(sz_node[i], st_node->nodename, 8);
sz_node[i][8] = '\0';
}
SQLGNCLS(us_hand_node, &sqlca);
for(i=0;i<us_count_node+1;i++)
{
WinSendDlgItemMsg(hWndDlg,
265,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_node[i]));
}
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* Radiobutton text: "Local" */
cwCheckDlgItem(hWndDlg, 256, TRUE);
cwCheckDlgItem(hWndDlg, 257, FALSE);
ch_type = '0';
ch_drive = '\0';
break;
case 257: /* Radiobutton text: "Remote" */
cwCheckDlgItem(hWndDlg, 257, TRUE);
cwCheckDlgItem(hWndDlg, 256, FALSE);
ch_type = '1';
ch_drive = '\0';
break;
case 262: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 263: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 264: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 270: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 265: /* List box */
{
us_node_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
265,
LM_QUERYSELECTION,
(short)NULL,
(short)NULL);
if (us_node_index == LIT_NONE)
{
strcpy(sz_rds_name,"--New--");
}
else
{
strcpy(sz_rds_name, sz_node[us_node_index]);
if ((pspace = strchr(sz_rds_name, ' ')) != NULL)
{
*pspace = '\0';
}
sz_rds_name[8] = '\0';
}
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
Cat = (CATStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_CAT);
/* Query radio button for current state, if set then */
/* set the dialog structure variable to the control ID */
if (WinSendDlgItemMsg(hWndDlg, 256,
BM_QUERYCHECK, 0L, 0L ))
Cat->YourWindowsTitleGoesHere = 256;
/* Query radio button for current state, if set then */
/* set the dialog structure variable to the control ID */
if (WinSendDlgItemMsg(hWndDlg, 257,
BM_QUERYCHECK, 0L, 0L ))
Cat->YourWindowsTitleGoesHere = 257;
if ((strcmp(sz_rds_name, "--New--")) == 0)
{
rc = WinDlgBox(HWND_DESKTOP, hWndDlg,
(PFNWP)NODEMsgProc,
0, IDLG_NODE, (PBYTE)hWndParent);
if (rc)
{
WinSendDlgItemMsg(hWndDlg,
265,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_node[us_count_node]));
}
break;
}
us_count_dir++;
memset(sz_comment, '\0', sizeof(sz_comment));
memset(sz_db_entry, '\0', sizeof(sz_db_entry));
memset(sz_alias[us_count_dir], '\0',
sizeof(sz_alias[us_count_dir]));
bit_flag.cat = TRUE;
WinQueryDlgItemText(hWndDlg, 262,
sizeof(sz_db_entry),
sz_db_entry);
if ((pspace = strrchr(sz_db_entry, ' ')) != NULL)
{
*pspace = '\0';
}
if (sz_db_entry[0] == 0)
{
DosBeep(500,750);
bit_flag.cat = FALSE;
}
else
{
strcpy(sz_dbase, sz_db_entry);
sz_dbase[8] = '\0';
}
strupr(sz_dbase);
WinQueryDlgItemText(hWndDlg, 263,
sizeof(sz_alias[us_count_dir]),
sz_alias[us_count_dir]);
if ((pspace = strrchr(sz_alias[us_count_dir], ' ')) != NULL)
{
*pspace = '\0';
}
if (sz_alias[us_count_dir][0] == 0)
{
DosBeep(500,250);
bit_flag.cat = FALSE;
}
strupr(sz_alias[us_count_dir]);
WinQueryDlgItemText(hWndDlg, 264,
sizeof(sz_comment),
sz_comment);
/*
us_node_index = (USHORT)WinSendDlgItemMsg(hWndDlg, 265,
LM_QUERYSELECTION, 0L, 0L);
if (ch_type == '1')
{
strcpy(sz_rds_name, sz_node[us_node_index]);
}
*/
if (bit_flag.cat)
{
SQLGCATD(strlen(sz_comment),
strlen(sz_rds_name),
strlen(sz_alias[us_count_dir]),
strlen(sz_dbase),
ch_drive,
0,
ch_type,
&sqlca,
sz_comment,
sz_rds_name,
sz_alias[us_count_dir],
sz_dbase);
if (sqlca.sqlcode != 0)
{
DosBeep(500,500);
}
WinDismissDlg(hWndDlg, TRUE);
}
else
{
us_count_dir--;
}
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case 268: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of CATMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY NODEMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
char *pspace;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
WinSendDlgItemMsg(hWndDlg, 261, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
WinSendDlgItemMsg(hWndDlg, 262, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
WinSendDlgItemMsg(hWndDlg, 263, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
WinSendDlgItemMsg(hWndDlg, 264, EM_SETTEXTLIMIT, (MPARAM)8, NULL);
WinSendDlgItemMsg(hWndDlg, 265, EM_SETTEXTLIMIT, (MPARAM)30, NULL);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 261: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 262: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 263: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 264: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
case 265: /* Entry field */
switch(SHORT2FROMMP(mp1)) /* switch on Notification Code */
{
case EN_SETFOCUS:/* Entry field is receiving the focus */
break;
case EN_KILLFOCUS: /* Entry field is losing the focus */
break;
default: /* Default other messages */
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
us_count_node++;
memset(sz_comment, '\0', sizeof(sz_comment));
memset(sz_node[us_count_node], '\0', sizeof(sz_node[us_count_node]));
memset(sz_partner_lu, '\0', sizeof(sz_partner_lu));
memset(sz_local_lu, '\0', sizeof(sz_local_lu));
memset(sz_mode, '\0', sizeof(sz_mode));
bit_flag.node = TRUE;
WinQueryDlgItemText(hWndDlg, 261,
sizeof(sz_mode),
sz_mode);
if ((pspace = strrchr(sz_mode, ' ')) != NULL)
{
*pspace = '\0';
}
if (sz_mode[0] == 0)
{
DosBeep(200,500);
bit_flag.node = FALSE;
}
WinQueryDlgItemText(hWndDlg, 262,
sizeof(sz_local_lu),
sz_local_lu);
if ((pspace = strrchr(sz_local_lu, ' ')) != NULL)
{
*pspace = '\0';
}
if (sz_local_lu == 0)
{
DosBeep(500,250);
bit_flag.node = FALSE;
}
WinQueryDlgItemText(hWndDlg, 263,
sizeof(sz_partner_lu),
sz_partner_lu);
if ((pspace = strrchr(sz_partner_lu, ' ')) != NULL)
{
*pspace = '\0';
}
if (sz_partner_lu == 0)
{
DosBeep(500,250);
bit_flag.node = FALSE;
}
WinQueryDlgItemText(hWndDlg, 264,
sizeof(sz_node[us_count_node]),
sz_node[us_count_node]);
if ((pspace = strrchr(sz_nodename, ' ')) != NULL)
{
*pspace = '\0';
}
if (sz_node[us_count_node][0] == 0)
{
DosBeep(500,250);
bit_flag.node = FALSE;
}
WinQueryDlgItemText(hWndDlg, 265,
sizeof(sz_comment),
sz_comment);
if ((pspace = strrchr(sz_comment, ' ')) != NULL)
{
*pspace = '\0';
}
if (bit_flag.node)
{
SQLGCATN(strlen(sz_comment),
strlen(sz_mode),
strlen(sz_partner_lu),
strlen(sz_local_lu),
strlen(sz_node[us_count_node]),
0,
&sqlca,
sz_comment,
sz_mode,
sz_partner_lu,
sz_local_lu,
sz_node[us_count_node]);
if (sqlca.sqlcode != 0)
{
DosBeep(500,500);
}
}
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case 268: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of NODEMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY NO_CONMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndFrame);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
WinDismissDlg(hWndDlg, TRUE);
break;
case 259: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinDismissDlg(hWndDlg, FALSE);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of NO_CONMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY UN_CATMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i;
static HWND hWndParent;
static char sz_un_dbase[9];
char *pspace;
static short us_cat_index;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
SQLGDOPS('0', &us_hand_dir, &us_count_dir, &sqlca);
for(i=0;i<us_count_dir;i++)
{
SQLGDGNE(us_hand_dir, &st_info, &sqlca);
strncpy(sz_un_alias[i], st_info->alias, 8);
sz_un_alias[i][8] = '\0';
WinSendDlgItemMsg(hWndDlg,
256,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_un_alias[i]));
}
SQLGDCLS(us_hand_dir, &sqlca);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* List box */
{
us_cat_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
256,
LM_QUERYSELECTION,
(short)NULL,
(short)NULL);
if (us_cat_index == LIT_NONE)
{
strcpy(sz_dbase,"--New--");
}
else
{
strcpy(sz_un_dbase, sz_un_alias[us_cat_index]);
if ((pspace = strchr(sz_un_dbase, ' ')) != NULL)
{
*pspace = '\0';
}
sz_un_dbase[8] = '\0';
}
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
SQLGUNCD(strlen(sz_un_dbase), &sqlca, sz_un_dbase);
if (sqlca.sqlcode != 0)
{
DosBeep(500,500);
}
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case 259: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of UN_CATMsgProc */
/***************************************************************************/
/* */
/* Dialog Window Procedure */
/* */
/* This procedure is associated with the dialog box that is included in */
/* the function name of the procedure. It provides the service routines */
/* for the events (messages) that occur because the end user operates */
/* one of the dialog box's buttons, entry fields, or controls. */
/* */
/* The SWITCH statement in the function distributes the dialog box */
/* messages to the respective service routines, which are set apart by */
/* the CASE clauses. Like any other PM window, the Dialog Window */
/* procedures must provide an appropriate service routine for their end */
/* user initiated messages as well as for the general PM messages (like */
/* the WM_CLOSE message). If a message is sent to this procedure for */
/* which there is no programmed CASE condition (no service routine), */
/* the message is defaulted to the WinDefDlgProc function, where it is */
/* disposed of by PM. */
/* */
/***************************************************************************/
MRESULT EXPENTRY UN_NODEMsgProc(hWndDlg, message, mp1, mp2)
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
static SHORT sfValidate = TRUE;
INT i, us_un_node_index;
static HWND hWndParent;
static char *pspace;
static char sz_un_node[9];
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
cwCenter(hWndDlg, (HWND)hWndParent);
SQLGNOPS(&us_hand_node, &us_count_node, &sqlca);
for(i=0;i<us_count_node;i++)
{
SQLGNGNE(us_hand_node, &st_node, &sqlca);
strncpy(sz_un_nodename[i], st_node->nodename, 8);
sz_un_nodename[i][8] = '\0';
WinSendDlgItemMsg(hWndDlg,
256,
LM_INSERTITEM,
MPFROM2SHORT(LIT_END,0),
MPFROMP(sz_un_nodename[i]));
}
SQLGNCLS(us_hand_node, &sqlca);
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
case 256: /* List box */
{
us_un_node_index = (USHORT)WinSendDlgItemMsg(hWndDlg,
256,
LM_QUERYSELECTION,
(short)NULL,
(short)NULL);
if (us_un_node_index == LIT_NONE)
{
strcpy(sz_rds_name,"--New--");
}
else
{
strcpy(sz_un_node, sz_un_nodename[us_un_node_index]);
if ((pspace = strchr(sz_un_node, ' ')) != NULL)
{
*pspace = '\0';
}
sz_un_node[8] = '\0';
}
}
break;
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK: /* Button text: "Ok" */
SQLGUNCN(strlen(sz_un_node), &sqlca, sz_un_node);
if (sqlca.sqlcode != 0)
{
DosBeep(400,500);
}
WinDismissDlg(hWndDlg, TRUE);
break;
case DID_CANCEL: /* Button text: "Cancel" */
/* Ignore data values entered into the dialog controls */
/* and dismiss the dialog window */
WinDismissDlg(hWndDlg, FALSE);
break;
case 259: /* Button text: "Help" */
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
break; /* End of WM_CLOSE */
case WM_FAILEDVALIDATE:
WinAlarm(HWND_DESKTOP, WA_ERROR);
sfValidate = FALSE;
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
sfValidate = TRUE;
return((MRESULT)TRUE);
break; /* End of WM_FAILEDVALIDATE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of UN_NODEMsgProc */
/***************************************************************************/
/* */
/* cwRegisterClass Function */
/* */
/* The following function registers all the classes of all the windows */
/* associated with this application. The function returns TRUE if it is */
/* successful, otherwise it returns FALSE. */
/* */
/***************************************************************************/
INT cwRegisterClass()
{
INT rc;
strcpy(szAppName, "LUDOSPY");
rc = WinRegisterClass(hAB, /* Anchor block handle */
(PCH)szAppName, /* Name of class being registered */
(PFNWP)WndProc, /* Window procedure for class */
CS_SIZEREDRAW ,
1*sizeof(char FAR *));
if (rc == FALSE)
return(FALSE);
return(TRUE);
} /* End of cwRegisterClass */
/***************************************************************************/
/* */
/* cwCreateWindow Function */
/* */
/* The following function is used to create a window (the main window, */
/* a child window, an icon window, etc.) and set it's initial size and */
/* position. It returns the handle to the frame window. */
/* */
/***************************************************************************/
HWND cwCreateWindow(
HWND hWndParent, /* Handle to the parent of the window to be created */
ULONG ctldata, /* Frame control flags for the window */
PCH appname, /* Class name of the window */
PCH title, /* Title of the window */
USHORT ResID, /* Resource id value */
INT x, /* Initial horizontal and vertical location */
INT y,
INT cx, /* Initial width and height of the window */
INT cy,
PHWND hWndClient, /* Handle to the client area of the window */
ULONG lfStyle, /* Frame window style */
USHORT uSizeStyle) /* User defined size and location flags */
{
USHORT rc; /* accepts return codes from function calls */
HWND hWndFrame; /* local handle to created window frame */
USHORT SizeStyle; /* local window positioning options */
CHAR MsgBuffer[80]; /* buffer for error messages */
HPS hPS; /* handle to a presentation space */
int xmod, ymod; /* modifiers for sizing */
#define DLGXMOD 4 /* Dialog units X modulo */
#define DLGYMOD 8 /* Dialog units Y modulo */
FONTMETRICS fm; /* structure for determing modifiers */
/* Create the frame window */
hWndFrame = WinCreateStdWindow(hWndParent, /* parent of window */
lfStyle, /* frame window style */
&ctldata, /* frame flags */
appname, /* class name */
title, /* window title */
0L, /* client window style */
0, /* module for resources */
ResID, /* resource id */
(HWND FAR *)hWndClient); /* client handle*/
/* if hWndFrame is NULL, an error occured when opening the window, */
/* notify the user and exit this function */
if(hWndFrame == 0)
{
WinLoadString(hAB, 0, IDS_ERR_WINDOW_CREATE, 80, MsgBuffer);
WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
/* set up size options */
SizeStyle = SWP_ACTIVATE | SWP_ZORDER | uSizeStyle;
/* if the height, width, intial x or initial y values are non-zero, */
/* then we will need to set up the modifiers for size and location */
if((cx > 0) || (cy > 0) ||
(x > 0) || (y > 0))
{
hPS = WinGetPS(HWND_DESKTOP);
GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
xmod = (INT)fm.lAveCharWidth;
ymod = (INT)fm.lMaxBaselineExt;
WinReleasePS(hPS);
}
/* if either the width or the height are non-zero, then the size of the */
/* created window will be changed, set SizeStyle accordingly */
if((cx > 0) || (cy > 0))
SizeStyle |= SWP_SIZE;
/* set the size and position of the window and activate it */
rc = WinSetWindowPos(hWndFrame, HWND_TOP, 0, 0,
(USHORT)(cx * xmod)/DLGXMOD,
(USHORT)(cy * ymod)/DLGYMOD, SizeStyle);
/* if the either the intial x or y position of the window is non-zero, */
/* set the window to its new position */
if((x > 0) || (y > 0))
rc = WinSetWindowPos(hWndFrame, HWND_TOP,
(USHORT)(x * xmod)/DLGXMOD,
(USHORT)(y * ymod)/DLGYMOD, 0, 0, SWP_MOVE);
/* if rc is not set to TRUE then WinSetWindowPos failed, notify the user*/
/* and exit this function */
if(!rc)
{
WinLoadString(hAB, 0, IDS_ERR_WINDOW_POS, 80, MsgBuffer);
WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
/* return the handle to the frame window */
return(hWndFrame);
} /* End of cwCreateWindow */
/***************************************************************************/
/* cwCenter Function */
/* */
/* Centers a dialog box on the client area of the caller */
/* */
/***************************************************************************/
INT cwCenter(hWnd, hWndParent)
HWND hWnd; /* handle of the window to be centered */
HWND hWndParent; /* handle of the window to center on */
{
ULONG SrcX, SrcY; /* Center of parent */
INT ix, iy; /* Destination points */
SWP DlgSwp, ParentSwp; /* Set window position structures */
ULONG ScreenWidth, ScreenHeight; /* Dimensions of the DESKTOP */
POINTL pt; /* Point */
/* Determine the width and height of the DESKTOP so the dialog box */
/* will not be positioned to a point off of the screen. */
ScreenWidth = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
ScreenHeight = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
/* Query width and depth of dialog box */
WinQueryWindowPos(hWnd, (PSWP)&DlgSwp);
/* Query width and depth of caller */
WinQueryWindowPos(hWndParent, (PSWP)&ParentSwp);
/* Map the point parent points to the Desktop */
pt.x = ParentSwp.x;
pt.y = ParentSwp.y;
/* Convert the point from having our window as the origin to having */
/* the DESKTOP as the origin */
WinMapWindowPoints(hWndParent, HWND_DESKTOP, &pt, 1);
SrcX = pt.x + (ParentSwp.cx / 2);
SrcY = pt.y + (ParentSwp.cy / 2);
/* Determine the point to move the dialog box to */
ix = (INT)(SrcX - (DlgSwp.cx / 2));
iy = (INT)(SrcY - (DlgSwp.cy / 2));
/* if either point is less than zero, then set that point to zero */
/* so the dialog box will not be positoned off of the window */
ix = (ix < 0) ? 0 : ix;
iy = (iy < 0) ? 0 : iy;
/* if either point plus the height or width of the dialog box is */
/* greater than the height or width of the screen adjust point */
if(((ULONG)ix + DlgSwp.cx) > ScreenWidth)
ix = (INT)(ScreenWidth - DlgSwp.cx);
if(((ULONG)iy + DlgSwp.cy) > ScreenHeight)
iy = (INT)(ScreenHeight - DlgSwp.cy);
/* move the dialog box */
return(WinSetWindowPos(hWnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE));
}
/* This function initializes the states of all dialog box radio buttons */
/* and check boxes that have had their initial status set to true */
INT cwSetInitDlgStatus(hWnd)
HWND hWnd;
{
CATStruct FAR *Cat;
OFFSETOF(Cat) = 0;
DosAllocSeg(sizeof(CATStruct), (PSEL)&SELECTOROF(Cat), 0);
lmemset(Cat, 0x00, sizeof(CATStruct));
WinSetWindowULong(hWnd, OFFSET_CAT, (ULONG)Cat);
Cat->YourWindowsTitleGoesHere = 257;
}
INT cwFreeDlgMemory(hWnd)
HWND hWnd;
{
CATStruct FAR *Cat;
Cat = (CATStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_CAT);
DosFreeSeg(SELECTOROF(Cat));
}
void lmemset(memptr, value, size)
void FAR *memptr;
char value;
int size;
{
char FAR *chrptr = memptr;
while (size--)
*chrptr++ = value;
}
/* LONGSTRCPY - is a functional equivalent to the C library routine */
/* strcpy, with the exception that it takes far pointers to */
/* to character strings as it's parameters. */
PSZ longstrcpy(target, source)
PSZ target;
PSZ source;
{
PSZ z = target;
while(*target++ = *source++);
return(z);
}
int cwCheckDlgItem(hWndDlg, id, state)
HWND hWndDlg;
INT id;
INT state;
{
return((INT)WinSendDlgItemMsg(hWndDlg, id,
BM_SETCHECK, MPFROMSHORT(state), 0L));
}
/*............................................................
: :
: ..........................................................:...........
: : :
:..: db_crash() :
: :
:...................................................................*/
void db_crash(void)
{
int x;
ltoa(sqlca.sqlcode, sz_code, 10);
if (!bit_flag.time)
{
while(!kbhit())
{
DosBeep(500,500);
DosSleep(DELAY);
}
}
DosBeep(500,500);
DosSleep(DELAY);
} /* end db_crash */
/*............................................................
: :
: ..........................................................:...........
: : :
:..: sort_users() :
: :
:...................................................................*/
void sort_users(void)
{
register int a;
register int b;
for(a=1;a<basestat.connects;a++)
{
basestat.ustat[100] = basestat.ustat[a];
b = a - 1;
while((b >= 0) && (strncmp(basestat.ustat[100].authid,
basestat.ustat[b].authid, 16)) < 0 )
{
basestat.ustat[b+1] = basestat.ustat[b];
b--;
}
basestat.ustat[b+1] = basestat.ustat[100];
}
} /* end sort_users() */
/*............................................................
: :
: ..........................................................:...........
: : :
:..: LimitLBox(HWND, USHORT) :
: :
:...................................................................*/
static FONTMETRICS g_font_metrics;
static SHORT sFontInitialized = 0;
static CHAR sz_temp_string[1024];
MRESULT EXPENTRY LimitLBox( HWND hWndDlg, USHORT sLength )
{
HPS hps;
if ( !sFontInitialized )
{
sFontInitialized = 1;
hps = WinBeginPaint( hWndDlg, NULL, NULL );
GpiQueryFontMetrics( hps, (LONG)sizeof(FONTMETRICS), &g_font_metrics );
WinEndPaint( hps );
}
return( MPFROM2SHORT( g_font_metrics.lMaxBaselineExt, sLength ) );
}
/*............................................................
: :
: ..........................................................:...........
: : :
:..: AlignLBox(HWND, USHORT, USHORT, MPARAM) :
: :
:...................................................................*/
MRESULT EXPENTRY AlignLBox( HWND hWndDlg, USHORT sResource,
USHORT *cols, MPARAM mparam2 )
{
POWNERITEM ptr_owner_item;
RECTL rectl;
POINTL ptl;
PCHAR psz_token;
memset( sz_temp_string, '\0', sizeof(sz_temp_string) );
ptr_owner_item = (POWNERITEM)PVOIDFROMMP( mparam2 );
WinSendDlgItemMsg( hWndDlg, sResource, LM_QUERYITEMTEXT,
MPFROM2SHORT( ptr_owner_item->idItem, sizeof(sz_temp_string) ),
MPFROMP( sz_temp_string ));
rectl.xLeft = ptr_owner_item->rclItem.xLeft;
rectl.yBottom = ptr_owner_item->rclItem.yBottom;
rectl.xRight = ptr_owner_item->rclItem.xRight;
rectl.yTop = ptr_owner_item->rclItem.yTop;
ptl.x = rectl.xLeft;
ptl.y = rectl.yBottom + g_font_metrics.lMaxDescender;
WinFillRect( ptr_owner_item->hps, &rectl, SYSCLR_WINDOW );
if ( ptr_owner_item->fsState == FALSE && ptr_owner_item->fsStateOld == TRUE )
GpiSetBackColor( ptr_owner_item->hps, CLR_WHITE );
psz_token = strtok( sz_temp_string, "~" );
while ( psz_token != NULL )
{
ptl.x += *cols++;
GpiCharStringAt( ptr_owner_item->hps, &ptl,
(LONG)strlen( psz_token ), psz_token );
psz_token = strtok( NULL, "~" );
}
if ( ptr_owner_item->fsState == FALSE && ptr_owner_item->fsStateOld == TRUE )
ptr_owner_item->fsStateOld = FALSE;
return (MRESULT) 1;
}
/*............................................................
: :
: ..........................................................:...........
: : :
:..: get_time() :
: :
:...................................................................*/
void get_time()
{
time(&bintime);
curtime = localtime(&bintime);
} /* end get_time() */
/*.............................................................
: :
: main :
: .......................................................:......
: : :
: : ctrl :
:......: ........................................................:......
: : :
: : :
:....: write_user_stats(void) :
: :
: :
:............................................................*/
void write_user_stats(void)
{
char sz_trans[17];
char sz_sql_con[17];
char sz_sql_trans[17];
char sz_trans_time[17];
unsigned short us_buff_size;
unsigned short i;
for(i=0;i<basestat.connects;i++)
{
strcpy(sz_user_buff, "User: ");
strncat(sz_user_buff, basestat.ustat[i].authid, 8);
strcat(sz_user_buff, " Node: ");
strncat(sz_user_buff, basestat.ustat[i].node, 8);
/*
strcat(sz_user_buff, " Auth. Level: ");
if (basestat.ustat[i].authority_lvl & SQL_SYSADM)
{
strcat(sz_user_buff, "SYS ADM");
}
if (basestat.ustat[i].authority_lvl & SQL_DBADM)
{
strcat(sz_user_buff, "DB ADM");
}
if (basestat.ustat[i].authority_lvl & SQL_CONNECT)
{
strcat(sz_user_buff, "CONNECT");
}
*/
strcat(sz_user_buff, " Connect Time: ");
con_time = bintime - basestat.ustat[i].connect_time;
out_time = localtime(&con_time);
strncat(sz_user_buff, asctime(out_time), 24);
strcat(sz_user_buff, " Trans/connect: ");
ltoa(basestat.ustat[i].con_trans, sz_trans, 10);
strncat(sz_user_buff, sz_trans, 16);
strcat(sz_user_buff, " SQL/connect: ");
ltoa(basestat.ustat[i].con_reqs, sz_sql_con, 10);
strncat(sz_user_buff, sz_sql_con, 16);
strcat(sz_user_buff, " SQL/trans: ");
ltoa(basestat.ustat[i].cur_reqs, sz_sql_trans, 10);
strncat(sz_user_buff, sz_sql_trans, 16);
strcat(sz_user_buff, " Sec. curr/trans: ");
ltoa(basestat.ustat[i].trans_time, sz_trans_time, 10);
strncat(sz_user_buff, sz_sql_trans, 16);
strcat(sz_user_buff, " T.S.: ");
if (basestat.ustat[i].trans_state == 'S')
{
strcat(sz_user_buff, "S");
}
if (basestat.ustat[i].trans_state == 'R')
{
strcat(sz_user_buff, "R");
}
if (basestat.ustat[i].trans_state == 'C')
{
strcat(sz_user_buff, "C");
}
strcat(sz_user_buff, " L.S.: ");
if (basestat.ustat[i].lock_state == 'W')
{
strcat(sz_user_buff, "W");
}
else
{
strcat(sz_user_buff, "N");
}
fprintf(spyfile, "%s\n", sz_user_buff);
} /* end of while */
fprintf(spyfile, "\n");
/* bit_flag.exit = TRUE; */
} /* end write_user_stats() */
/*.............................................................
: :
: main :
: .......................................................:......
: : :
: : ctrl :
:......: ........................................................:......
: : :
: : :
:....: write_db_stats() :
: :
: :
:............................................................*/
void write_db_stats()
{
strncpy(sz_buff, basestat.release_lvl, 4);
strcat(sz_buff, " ");
strncat(sz_buff, basestat.corr_serv_lvl, 8);
fprintf(spyfile, "%s\n", sz_buff);
strcpy(sz_buff, "Database Name: ");
strncat(sz_buff, basestat.db_name, 16);
fprintf(spyfile, "%s\n", sz_buff);
strcpy(sz_buff, "Database alias: ");
strncat(sz_buff, basestat.db_alias, 16);
fprintf(spyfile, "%s\n", sz_buff);
strcpy(sz_buff, "Drive: ");
strncat(sz_buff, basestat.drive, 2);
fprintf(spyfile, "%s\n", sz_buff);
strcpy(sz_buff, "Location: ");
if (basestat.location == 'L')
{
strcat(sz_buff, "Local");
}
else
{
strcat(sz_buff, "Remote");
}
fprintf(spyfile, "%s\n", sz_buff);
strcpy(sz_buff, "Node: ");
strncat(sz_buff, basestat.node, 8);
fprintf(spyfile, "%s\n", sz_buff);
strcpy(sz_buff, "Current connects: ");
itoa(basestat.connects, sz_conns, 10);
strcat(sz_buff, sz_conns);
fprintf(spyfile, "%s\n", sz_buff);
get_time();
fprintf(spyfile, "%s\n", asctime(curtime));
fprintf(spyfile, "\n");
} /* end of write_db_stats() */
/*.............................................................
: :
: :
: refresh_thread() :
: :
: :
:............................................................*/
void refresh_thread(void)
{
short i;
while(!bit_flag.tend)
{
for(i=0;i<us_scan;i++)
{
DosSleep(SLEEP_TIME);
}
if (!bit_flag.draw)
{
WinPostMsg(hWndReFresh, WM_REDRAW, 0L, 0L);
}
}
_endthread();
} /* end of refresh_thread() */
/*.............................................................
: :
: :
: wch_thread() :
: :
: :
:............................................................*/
void wch_thread(void)
{
static short i;
for(i=0;i<(us_scan * 3);i++)
{
DosSleep(SLEEP_TIME);
if (bit_flag.time)
{
_endthread();
}
}
if (!bit_flag.time)
{
db_crash();
}
_endthread();
} /* end of wch_thread() */